
<div class="posts xpost fx fxcolumn">
    <?php if (isset($args['data']['posts']) && is_array($args['data']['posts']) && !empty($args['data']['posts'])) : ?>
        <?php foreach ($args['data']['posts'] as $post) : ?>
            <div class="item fx fx_jc_between brds">
                <div class="item_info fx fxcolumn gap fx_ai_end">
                    <span class="item_time btn ala"><?php echo $post['date']; ?></span>
                    <h2 class="nowrap2 ala"><a href="<?php echo $post['link']; ?>"><?php echo $post['title']; ?></a></h2>
                    <p class="nowrap2 ala"><?php echo $post['excerpt']; ?></p>
                    <a href="<?php echo $post['link']; ?>" class="btn item_link">المزيد</a>
                </div>
                <a class="item_img fx fx_jc_center" href="<?php echo $post['link']; ?>">
                    <img data-src="<?php echo $post['thumbnail']; ?>" alt="<?= $post['title'] ?>">
                </a>
            </div>
        <?php endforeach; ?>
    <?php else : ?>
        <?php if (isset($args['showEmpty']) && $args['showEmpty']) : ?>
            <p class="empty-message">لا توجد منشورات متاحة حاليا.</p>
        <?php endif; ?>
    <?php endif; ?>
</div>

<?php if (isset($args['showPage']) && $args['showPage'] && isset($args['data']['total_pages']) && $args['data']['total_pages'] > 1) : ?>
    <div class="pagination">
        <?php
        echo paginate_links(array(
            'total' => $args['data']['total_pages'],
            'current' => $args['data']['current_page'],
            'prev_text' => __('« Previous'),
            'next_text' => __('Next »'),
        ));
        ?>
    </div>
<?php endif; ?>
